package com.lzy.cloud.order.service.impl;

import com.lzy.cloud.order.dtos.OrderRefundMoneyDto;
import com.lzy.cloud.order.entity.OrderRefundMoney;
import com.lzy.cloud.order.mapper.OrderRefundMoneyMapperExt;
import com.lzy.cloud.order.service.OrderRefundMoneyService;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 订单退换货金额明细
 * @Author:   gyl
 * @Date:     2018/7/10 20:23
 */
@Service
public class OrderRefundMoneyServiceImpl implements OrderRefundMoneyService {

    @Autowired
    private OrderRefundMoneyMapperExt orderRefundMoneyMapperExt;

    @Override
    public List<OrderRefundMoneyDto> queryList(OrderRefundMoneyDto orderRefundMoneyDto) {
        return orderRefundMoneyMapperExt.queryList(orderRefundMoneyDto);
    }

    @Override
    public Long create(OrderRefundMoneyDto orderRefundMoneyDto) {
        OrderRefundMoney orderRefundMoney = DozerUtils.map(orderRefundMoneyDto, OrderRefundMoney.class);
        return orderRefundMoneyMapperExt.insertSelective(orderRefundMoney)>0 ? orderRefundMoney.getId() : 0;
    }

    @Override
    public void deleteByRefundId(Long refundId) {
        orderRefundMoneyMapperExt.deleteByRefundId(refundId);
    }

    @Override
    public Boolean update(OrderRefundMoneyDto orderRefundMoneyDto) {
        return orderRefundMoneyMapperExt.updateByPrimaryKeySelective(DozerUtils.map(orderRefundMoneyDto, OrderRefundMoney.class)) > 0;
    }
}
